home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / HARDWARE / AUTOVIDC / Source100 (.txt) < prev   
RISC OS BBC BASIC V Source  |  1995-02-24  |  10KB  |  260 lines

  1.  > <VidcEnh>.Source
  2.  VIDC-Enhancer-Umschalter
  3.  Schaltet die Leitung AUX1 auf aktiv-1 in bestimmten Bildschirmmodi.
  4.  Das Originalprogramm musste unbedingt umgebaut werden, weil es nicht
  5.  bei Mode 12 oder aehnlichen zugeschaltet hat und nicht konfigurierbar war.
  6.  Version 0.99
  7.  - Ruft auch bei Init den Modus ab.
  8.  - Untersucht eine interne Tabelle und stellt danach Aux1 ein.
  9.  Version 1.00
  10.  - Befehle eingebaut um Konfiguration abzufragen und zu aendern.
  11.  - Hardware wird geprueft, ob der richtige Rechner vorliegt.
  12.    Hardwarepruefung durch OS_ReadSysInfo 2 (PRM 1-722)
  13.    Gibt's nicht im RO2 --> alte Hardware automatisch.
  14.    Wenn vorhanden, dann muessen R0-R4 = 0 sein, sonst neue Hardware.
  15.  code% 2048
  16. "*** Error: "
  17. $" in "
  18. name$    = "RAM:$.AutoVIDC"
  19. version$ = "1.00"
  20. date$    = "24 Feb 1995"
  21. modname$ = "AutoVIDC"
  22. OS_WriteI = &100
  23. XOS_WriteI = &100 + (1<<17)
  24. *Key 1 AutoVIDCmap
  25. *Key 2 AutoVIDCset
  26. *Key 3 RAM:AutoVIDC
  27.  "Assembling :"
  28.  Pass% = 4 
  29. O%=code%:P%=&00000000
  30. [OPT Pass%
  31. .Start%
  32. *(    EQUD &00000000           ; Start
  33. +'    EQUD Init%               ; Init
  34. ,'    EQUD &00000000           ; Fini
  35. -0    EQUD Service%            ; Service-Calls
  36. ./    EQUD Title%              ; Title-String
  37. /.    EQUD Help%               ; Help String
  38. 08    EQUD Comands%            ; Keywords & help table
  39. 18    EQUD &00000000           ; SWI chunk base number
  40. 22    EQUD &00000000           ; SWI Handlercode
  41. 35    EQUD &00000000           ; SWI Decoding Table
  42. 44    EQUD &00000000           ; SWI Decoding Code
  43. .Title%
  44.     EQUS modname$
  45.     EQUB &00
  46. .Help%
  47.     EQUS modname$ + 
  48. :*    EQUS version$ + " (" + date$ + ")"
  49.     EQUB &00
  50.     ALIGN
  51. .Comands%
  52. ?2    EQUS modname$ + 
  53. 0        ; Command-string
  54.     ALIGN
  55. A3    EQUD &00000000               ; command-code
  56. B7    EQUD &00000000               ; Information-word
  57. C=    EQUD &00000000               ; invalid-syntax-message
  58. D0    EQUD helpme%                 ; help-text
  59.     EQUS "AutoVIDCmap" + 
  60.     ALIGN
  61.     EQUD map%
  62.     EQUD 0
  63.     EQUD 0
  64.     EQUD helpmap%
  65.     EQUS "AutoVIDCset" + 
  66.     ALIGN
  67.     EQUD Set%
  68. PE    EQUD 1 + (128<<16)           ; min. + max. no. of parameters.
  69.     EQUD syntaxSet%
  70.     EQUD helpSet%
  71. T>    EQUD &00000000               ; Command = 0 = EndofList
  72. .helpme%
  73.     EQUS modname$ + 
  74. X*    EQUS version$ + " (" + date$ + ")"
  75. Y$    EQUS " 
  76.  Andreas Barth" +
  77. ZH    EQUS "Listens to Mode-changes and sets AUX1 accordingly to its "
  78. [I    EQUS "internal modelist to 'active 1' to enable a VIDC enhancer."
  79.     EQUB &00
  80. .helpmap%
  81. _U    EQUS "AutoVIDCmap shows the map of the current settings for each screenmode."
  82. `X    EQUS " The Format ist 'Map: <Modenumber>+ <Modenumber>- ...' for all 128 Modes."
  83. aB    EQUS " The + and - shows whether Aux1 is switched or not."
  84.     EQUB 0
  85. .helpSet%
  86. eQ    EQUS "AutoVIDCset <Modenumber><+|-> [...] changes the setting for one or"
  87. f6    EQUS " more screenmodes to '+'=ON or '-'=OFF."
  88.     EQUB 0
  89. .syntaxSet%
  90. j7    EQUS "use *AutoVIDCset <Modenumber><+|-> [...]"
  91.     EQUB 0
  92.     ALIGN
  93. n?.LatBShadow% EQUD &00000105      ; contains Value of LatchB
  94. oA.LatchB%     EQUD &03350018      ; Hardware address of LatchB
  95. ; Here's the Mode-List
  96. qK; Lowest bit is for Mode 0, going up, every line has 32 bits and modes.
  97. r7;                  31-----------------------------0
  98. s7.ModeList%   EQUD %11100000000000000000000000000000
  99. t7             EQUD %00000000000000000000000000000001
  100. u7             EQUD %00000000000000000000000000000000
  101. v7             EQUD %00000000000000000000000000000000
  102. x*; I've marked mode 32 as 'enhanced'...
  103. ; Initialisation code
  104. |D; Check the Hardware. We can only run on old machines which have
  105. }J; the Aux-Hardware installed. Otherwise we fuddle in unknown hardware.
  106. ~0; RO2 would be ok, only old machines got it.
  107. 1; Otherwise not features should be displayed.
  108. .Init%
  109.      STMFD   R13!,{R0-R4,R14}
  110. A    MOV     R0,#2                ; Read Chip presence and ID.
  111. @    SWI     "XOS_ReadSysInfo"    ; (doesn't exist under RO2)
  112. 5    BVS     itsreallyold%        ; RO2 is okay...
  113. D    
  114. R     R0,R0,R1             ; It exists, so test the values.
  115. R     R0,R0,R2
  116. R     R0,R0,R3
  117. I    
  118. RS    R0,R0,R4             ; is > 0, if new hardware is present.
  119.     BEQ     itsreallyold%
  120.      LDMFD   R13!,{R0-R4,R14}
  121.     ADR     R0,initerror%
  122. ;    
  123. RS    PC,R14, #1<<28       ; Set V-flag and return
  124. .itsreallyold%
  125.      LDMFD   R13!,{R0-R4,R14}
  126. .ReInit%
  127. ;    MOV     R1,#&46              ; Let's do our service
  128. ; Service Call handler
  129. (; We only check for a Mode-change...
  130. .Service%
  131.      STMFD   R13!,{R0-R2,R14}
  132. 9    TEQ     R1,#&46              ; Service_ModeChange
  133.      LDMNEFD R13!,{R0-R2,PC}^
  134. 6    MOV     R0,#&87              ; get Mode-number
  135. 0    SWI     "XOS_Byte"           ; now in R2
  136. ,; Now check if this mode has its Bit set
  137.      R2,R2,#127
  138.     ADR     R0,ModeList%
  139. ?    ADD     R0,R0,R2,LSR #3      ; Tablebase + (Mode /32*4)
  140. P    BIC     R0,R0,#3             ; Clear lowest 2 Bits. (now necessary here)
  141. 8    LDR     R0,[R0]              ; get part of Table
  142. 6    
  143.      R2,R2,#31            ; mask shift amount
  144. :    ADD     R2,R2,#1             ; always shift one !!
  145. D    MOVS    R0,R0,LSR R2         ; shift Tablebit into Carryflag
  146. -; Now the carryflag contains the Mode-bit
  147. ; and is '1' for VIDC-mode
  148. D    LDR     R0,LatBShadow%       ; Load address of Aux1-contents
  149. D    LDR     R1,LatchB%           ; Load address of Aux1-Hardware
  150. 7    LDRB    R2,[R0,#0]           ; Load Aux1-Shadow
  151. 3    
  152. RCS   R2,R2,#&20           ; set Aux1-Bit.
  153. 6    BICCC   R2,R2,#&20           ; reset Aux1-Bit.
  154. 6    STRB    R2,[R0,#0]           ; set Aux1-Shadow
  155. 8    STRB    R2,[R1,#0]           ; set Aux1-Hardware
  156.      LDMFD   R13!,{R0-R2,PC}^
  157. L; AutoVIDCmap shows the map of the current settings for each screenmode.
  158. N; The Format ist 'Map; <Modenumber>+ <Modenumber>- ...' for all 128 Modes.
  159. 8; The + and - shows whether Aux1 is switched or not.
  160.     .map%
  161.      STMFD   R13!,{R0-R6,R14}
  162.     SWI     "XOS_WriteS"
  163.     EQUS    " Map: "+
  164.     ALIGN
  165. 1    MOV     R4,#0                ; Modenumber
  166. 6    ADR     R5,ModeList%         ; Pointer to Map.
  167. .stloop1%
  168. V    LDR     R6,[R5],#4           ; Load first Byte from Map and increment pointer.
  169. .stloop2%
  170.     ; print modenumber
  171.     MOV     R0,R4
  172.     ADR     R1,buffer%
  173.     MOV     R2,#8
  174. &    SWI     "XOS_ConvertCardinal1"
  175.     SWI     "XOS_Write0"
  176.     ; decode map setting
  177. C    MOVS    R6,R6,LSR #1         ; shift lowest bit into carry.
  178. !    SWICC   XOS_WriteI + 
  179. !    SWICS   XOS_WriteI + 
  180.     SWI     XOS_WriteI + 32
  181.     ; finish the loops
  182. ;    ADD     R4,R4,#1             ; increment modenumber
  183. :    CMP     R4,#128              ; all modes printed ?
  184.     SWIEQ   "XOS_NewLine"
  185.     LDMEQFD R13!,{R0-R6,PC}
  186. ?    CMP     R4,#32               ; check for boundaries and
  187.     CMPNE   R4,#64
  188.     CMPNE   R4,#96
  189.     BNE     stloop2%
  190. 9    BEQ     stloop1%             ; get next mapentry.
  191. I; AutoVIDCset <Modenumber><+|-> [...] changes the setting for one or"
  192. *; more screenmodes to '+'=
  193.  or '-'=
  194.     .Set%
  195.      STMFD   R13!,{R0-R6,R14}
  196. ;    MOV     R4,R1                ; number of parameters
  197. 8    MOV     R1,R0                ; pointer to string
  198. .setloop%
  199. <    CMP     R4,#0                ; any parameters left ?
  200.      LDMEQFD R13!,{R0-R6,R14}
  201. I    BEQ     ReInit%              ; do a new init, maybe we changed...
  202. <    SUB     R4,R4,#1             ; decrement parameters.
  203.     ; Scan for modenumber
  204. S    MOV     R0,#10               ; base; R1 is still pointing to next argument.
  205. 4    MOV     R2,#127              ; maximum value
  206. "    SWI     "XOS_ReadUnsigned"
  207. 3    LDMVSFD R13!,{R0-R6,R14}     ; Any errors ?
  208.     ADR     R0,seterror%
  209. ;    
  210. RVSS  PC,R14, #1<<28       ; Set V-flag and return
  211. <    CMP     r2,#128              ; is it a valid value ?
  212.     ADDCS   R1,R1,#1
  213. 6    BCS     setloop%             ; No, then ignore
  214.      ; Get the mode-bit ready
  215. 5    ADR     R0,ModeList%         ; Get Tablebase.
  216. ?    ADD     R0,R0,R2,LSR #3      ; Tablebase + (Mode /32*4)
  217. ;    BIC     R0,R0,#3             ; Clear lowest 2 Bits.
  218. =    LDR     R5,[R0]              ; get this part of Table
  219. F    MOV     R3,#1                ; This is our bit for that entry,
  220. 6    
  221.      R2,R2,#31            ; mask shift amount
  222. I    MOV     R3,R3,LSL R2         ; shift our bit to correct position.
  223. '    ; Check the sign for '+' or '-'
  224. @    ldrb    r2,[r1]              ; load the signal-character
  225. 3    cmp     r2,#
  226. "+"           ; and decide....
  227. <    
  228. Req   R5,R5,R3             ; ...Set the bit to one.
  229. '    cmp     r2,#
  230. "-"           ; or
  231. @    BICeq   R5,R5,R3             ; ...Reset the bit to zero.
  232. "    ; Store the mode-bit again
  233.     STR     R5,[R0]
  234. S    ADD     R1,R1,#1             ; Increment string-pointer for next parameter.
  235.     B       setloop%
  236. .initerror%
  237.     EQUD 0
  238. M    EQUS "AutoVIDC is only suitable for older Archimedes computers using"
  239.     '    EQUS " a VIDC-Enhancer !!" + 
  240.     ALIGN
  241. .seterror%
  242.     EQUD 0
  243. 0    EQUS "Bad data in command string !" + 
  244.     ALIGN
  245. .buffer%
  246.     EQUD 0
  247.     EQUD 0
  248.     EQUD 0
  249.     .End%
  250.  "Pass ";Pass%;" successful..."
  251.  Pass%
  252.  "SAVE "+name$+" "+
  253. ~(code%)+" "+
  254. ~(O%)
  255.  "SETTYPE "+name$+" &FFA"
  256.  "SAVEd "+name$+" "+
  257. ~(code%)+" "+
  258. ~(O%)
  259. "*Filer_OpenDir RAM::RamDisc0.$
  260.